<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
        <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
    </head>
    <body>
        <div class="container">
            <h2>基本使用</h2>
            <button class="btn btn-primary">发送get请求</button>
            <button class="btn btn-warning">发送post请求</button>
        </div>
        <script>
            console.log(axios);
            // 获取按钮
            const btn = document.querySelectorAll("button");

            // 创建实例对象  段子接口   https://api.apiopen.top/getJoke
            const duanzi = axios.create({
                baseURL:"https://api.apiopen.top",
                timeout:2000
            })
            // 这里输出的duanzi和axios对象的功能几乎一样的
            console.log(duanzi);
 
            duanzi({
                url:"/getJoke"
            }).then(response =>{
                console.log(response);
            })

            /* duanzi.get('/getJoke').then(response=>{
                console.log(response.data);
            }) */
        </script>
    </body>
</html>